/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Chien
 */
@Entity
@Table(name = "TBL_PRIZE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Prize.findAll", query = "SELECT p FROM Prize p"),
    @NamedQuery(name = "Prize.findByPrizeId", query = "SELECT p FROM Prize p WHERE p.prizeId = :prizeId"),
    @NamedQuery(name = "Prize.findByTitle", query = "SELECT p FROM Prize p WHERE p.title = :title"),
    @NamedQuery(name = "Prize.findByDescription", query = "SELECT p FROM Prize p WHERE p.description = :description"),
    @NamedQuery(name = "Prize.findByPrizeDate", query = "SELECT p FROM Prize p WHERE p.prizeDate = :prizeDate"),
    @NamedQuery(name = "Prize.findByIsDeleted", query = "SELECT p FROM Prize p WHERE p.isDeleted = :isDeleted")})
public class Prize implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "PrizeId")
    private Integer prizeId;
    @Size(max = 255)
    @Column(name = "Title")
    private String title;
    @Size(max = 2000)
    @Column(name = "Description")
    private String description;
    @Column(name = "PrizeDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date prizeDate;
    @Column(name = "isDeleted")
    private Boolean isDeleted;
    @OneToMany(mappedBy = "prizeId")
    private List<Winner> winnerList;
    @JoinColumn(name = "EventId", referencedColumnName = "EventId")
    @ManyToOne
    private Event eventId;

    public Prize() {
    }

    public Prize(Integer prizeId) {
        this.prizeId = prizeId;
    }

    public Integer getPrizeId() {
        return prizeId;
    }

    public void setPrizeId(Integer prizeId) {
        this.prizeId = prizeId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getPrizeDate() {
        return prizeDate;
    }

    public void setPrizeDate(Date prizeDate) {
        this.prizeDate = prizeDate;
    }

    public Boolean getIsDeleted() {
        return isDeleted;
    }

    public void setIsDeleted(Boolean isDeleted) {
        this.isDeleted = isDeleted;
    }

    @XmlTransient
    public List<Winner> getWinnerList() {
        return winnerList;
    }

    public void setWinnerList(List<Winner> winnerList) {
        this.winnerList = winnerList;
    }

    public Event getEventId() {
        return eventId;
    }

    public void setEventId(Event eventId) {
        this.eventId = eventId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (prizeId != null ? prizeId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Prize)) {
            return false;
        }
        Prize other = (Prize) object;
        if ((this.prizeId == null && other.prizeId != null) || (this.prizeId != null && !this.prizeId.equals(other.prizeId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Prize[ prizeId=" + prizeId + " ]";
    }
    
}
